/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: StaticFactory
 * Author:   zhouheng
 * Date:     2019/5/1 10:00
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.zhouh.patterns.com.zhouh.create.factory.simpleFactory;

import com.zhouh.patterns.com.zhouh.entity.Fruit;
import com.zhouh.patterns.com.zhouh.entity.fruit.Apple;
import com.zhouh.patterns.com.zhouh.entity.fruit.Banana;
import com.zhouh.patterns.com.zhouh.entity.fruit.Orange;

/**
 * 〈一句话功能简述〉<br> 
 * 〈静态工厂〉
 *
 * @author zhouheng
 * @create 2019/5/1
 * @since 1.0.0
 */
public class StaticFactory {
    // apple
    public static final int TYPE_APPLE = 1;
    // banana
    public static final int TYPE_BANANA = 2;
    // orange
    public static final int TYPE_ORANGE = 3;

    /**
     * @description: 根据对象类型创建对象
     * @date: 2019/5/1 10:08
     * @author:zhouheng
     */
    public static Fruit getFruit(int type){
        if (type == TYPE_APPLE){
            return new Apple();
        }else if (type == TYPE_BANANA){
            return new Banana();
        }else if (type == TYPE_ORANGE){
            return new Orange();
        }

        return null;
    }
}